package com.ehome.poct.core.dao.mybatis;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ehome.mybatisplus.support.AbstractCrudRepository;
import com.ehome.poct.core.api.dto.report.TestConfClinicalReportAnalyseDTO;
import com.ehome.poct.core.dao.entity.report.TestConfClinicalReportAnalyseDO;
import com.ehome.poct.core.dao.mybatis.mapper.report.TestConfClinicalReportAnalyseMapper;
import com.ehome.poct.core.repository.report.TestConfClinicalReportAnalyseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
 * 检测临床智能解读配置表RepositoryImpl
 *
 * @author muqiu
 * @Date 2022-10-18 11:37
 */
@Repository
public class TestConfClinicalReportAnalyseRepositoryImpl extends AbstractCrudRepository<TestConfClinicalReportAnalyseDO, TestConfClinicalReportAnalyseDTO> implements TestConfClinicalReportAnalyseRepository {
    @Autowired private TestConfClinicalReportAnalyseMapper testConfClinicalReportAnalyseMapper;
    @Override
    public TestConfClinicalReportAnalyseDTO getByCode(String clinicalAnalyseCode, Integer patientType) {
        return BeanUtil.toBean(testConfClinicalReportAnalyseMapper.selectOne(Wrappers.<TestConfClinicalReportAnalyseDO>lambdaQuery().
                eq(TestConfClinicalReportAnalyseDO::getClinicalAnalyseCode,clinicalAnalyseCode)
                .eq(TestConfClinicalReportAnalyseDO::getPatientType,patientType)
                .last(" limit 1")
        ),TestConfClinicalReportAnalyseDTO.class);
    }
}
